// const path = require("path")
const {
  resolve

} = require("path")
const merge = require("webpack-merge")
const { bases } = require("./webpack.base")
const webpack = require("webpack")
module.exports = merge(bases, { // webpack基于node构建的
  mode: "development", // production
  watch: true,
  watchOptions: {
    poll: 1000,
    // aggregateTimeOut: 500,
    ignored: /node_modules/
  },

  entry: ["webpack-hot-middleware/client?onInfo=true&reload=true", `${process.cwd()}/src/index.js`],
  output: {
    filename: "main.js", // 通过热加载输出script文件挂载在目录与index.HTML一样
    path: resolve(process.cwd(), "dist")
  },
  // production 提供了约定大于配置 约定打包文件是src/index ->dist/main
  devServer: {
    host: "http://localhost",
    port: 7000,
    hot: true,
    grogress: true,
    historyApiFallback: true
    // true 表示webpack支持使用history false路由默认是hash
  },
  devtool: "source-map",
  performance: {
    hints: "warning", // false关闭提示 下面设置就没必要了
    // 入口起点的最大体积
    maxEntrypointSize: 50000000,
    // 生成文件的最大体积
    maxAssetSize: 30000000,
    // 只给出 js 文件的性能提示
    assetFilter: function (assetFilename) {
      return assetFilename.endsWith(".js")
    }
  },
  plugins: [new webpack.HotModuleReplacementPlugin()]
})
